$:.unshift(File.expand_path('../../lib', File.dirname(__FILE__)))

require 'rubygems'
require 'benchmark'
require 'builder'
require 'notator'

Benchmark.bm do |b|

  b.report( 'JSON' ) do

    15000.times do
      
      j = Notator::JavascriptObjectNotation.new()
      
      j.name "OnTerra Research Inc."
      j.address do
        j.street  "5400 Carillon Point."
        j.street2 "Building 5000"
        j.city    "Kirkland"
        j.state   "WA"
        j.zip     98029
      end

      j.array! :platforms do
        j.value! :mac_os_x
        j.value! :windows
        j.value! :web
        j.value! :ios
        j.value! :android
      end

      j.technologies [ 'ruby', 'mysql', 'mongodb', ]

      j.to_json

    end
  end
  
  b.report( 'JSON Pretty' ) do
    
    15000.times do
      
      j = Notator::JavascriptObjectNotation.new( :pretty => true )
      
      j.name "OnTerra Research Inc."
      j.address do
        j.street  "5400 Carillon Point."
        j.street2 "Building 5000"
        j.city    "Kirkland"
        j.state   "WA"
        j.zip     98029
      end

      j.array! :platforms do
        j.value! :mac_os_x
        j.value! :windows
        j.value! :web
        j.value! :ios
        j.value! :android
      end

      j.technologies [ 'ruby', 'mysql', 'mongodb', ]

      j.to_json
    
    end
    
  end
  
  b.report( 'Builder' ) do
    
    15000.times do
      
      xml = Builder::XmlMarkup.new( :indent => 2 )
      
      xml.name "OnTerra Research Inc."
      xml.address do
        xml.street  "5400 Carillon Point."
        xml.street2 "Building 5000"
        xml.city    "Kirkland"
        xml.state   "WA"
        xml.zip     98029
      end

      xml.technologies [ 'ruby', 'mysql', 'mongodb', ]

      xml.target!
            
    end
    
  end
  
end
